package com.xing.demo;

import java.util.Scanner;

public class 长跑中途退出例子 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String answer;
        int count=0;

        do {
            count++;
            System.out.println("小张开始跑："+count+"圈");
            System.out.println("=================");
            System.out.println("小张跑完了："+count+"圈");
            System.out.println("还能坚持吗？y/n");
            answer = input.next();
            if(!answer.equals("y")){
                break;//跳出循环
            }

        }while (count<10);
        System.out.println("比赛结束了，小张共跑了："+count+"圈");


    }
}
